/* test_image.cpp */

#include <iostream>
#include <string>
#include <vector>
#include <boost/assign/list_of.hpp>

#include <dodo_plot/dodo_plot.h>
#include <dodo_plot/widget/blank.h>
#include <dodo_plot/widget/image.h>
#include <dodo_plot/kernel/colormap.h>
#include <dodo_plot/widget/axis.h>
#include <dodo_plot/widget/colorbar.h>

using namespace std;
using namespace boost::assign;
using namespace dodo_plot;
using namespace dodo_plot::color_name;
const int W = 30;
const int H = 20;

int main(int argc, char *argv[])
{
	Blank blank(800, 600);
		
	vector<int> indexes = list_of(0)(32)(64)(96)(128)(160)(200)(256);
	vector<Color> colors = list_of(ORCHID)(RED)(YELLOW)(LAWNGREEN)(GREEN)(DARKCYAN)(BLUE)(PURPLE);

	Colormap colormap(indexes.begin(), indexes.end(),
		colors.begin());

	unsigned char data[H][W];
	for(int i = 0; i < H; ++i)
	{
		for(int j = 0; j < W; ++j)
		{
			data[i][j] = (unsigned char)(i / 2.0 / H * 256 + 
				j / 2.0 / W * 256);
		}
	}
	
	Image image(W, H, &data[0][0], colormap, true);
	image.rotate_270();
	cout << image.width() << " " << image.height() << endl;
	Picture final = combi(blank, frame(image, 400, 300));

	Axis axis(0, 256, 64, 0, 0);
	Colorbar colorbar(400, 15, colormap, axis, Colorbar::HORIZONTAL, true);

	Axis axis2(0, 256, 16, 0, 0, RIGHT);
	Colorbar colorbar2(10, 300, colormap, axis2, Colorbar::VERTICAL, true);

	final = combi(final, colorbar, BOTTOM_INSIDE | SIZE_LOCK, 0, -60);
	final = combi(final, colorbar2, RIGHT_INSIDE | SIZE_LOCK, -100, 0);

	Canvas canvas;
	canvas.resize_as(final);
	canvas.draw(final);
	canvas.write_png("image.png");
	

	return 0;
}

